package com.twu.biblioteca;

public class Menu {
    private Action[] actions;
    int MENU_LENGTH = 5;

    public Menu() {
        actions = new Action[MENU_LENGTH];
    }

    public void setAction(int index, Action action) {
        actions[index - 1] = action;
    }

    public String optionChosen(int index) {
        String result;

        if (index > MENU_LENGTH || actions[index - 1] == null) {
            result = "Select a valid option!!";
        } else {
            result = actions[index - 1].execute();
        }
        return result;
    }
}
